﻿using System;
using HttpApiGateway;
using HttpApiGateway.Model;
using RpcHelper.Validate;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
        /// <summary>
        /// 广播指令节点
        /// </summary>
        internal class DictateNodeController : ApiController
        {
                private readonly IDictateNodeService _Service;

                public DictateNodeController (IDictateNodeService service)
                {
                        this._Service = service;
                }
                /// <summary>
                /// 添加节点
                /// </summary>
                /// <param name="add"></param>
                /// <returns></returns>
                public long Add (DictateNewNode add)
                {
                        return this._Service.Add (add);
                }
                /// <summary>
                /// 删除节点
                /// </summary>
                /// <param name="id"></param>
                public void Drop ([NumValidate ("rpc.dictate.id.error", 1)] long id)
                {
                        this._Service.Drop (id);
                }
                /// <summary>
                /// 获取节点
                /// </summary>
                /// <param name="id"></param>
                /// <returns></returns>
                public DictateNode Get ([NumValidate ("rpc.dictate.id.error", 1)] long id)
                {
                        return this._Service.Get (id);
                }
                /// <summary>
                /// 获取所有节点
                /// </summary>
                /// <returns></returns>
                public DictateNode[] GetAll ()
                {
                        return this._Service.Gets ();
                }
                /// <summary>
                /// 获取摸个父级节点
                /// </summary>
                /// <param name="parentId"></param>
                /// <returns></returns>
                public DictateNode[] Gets ([NumValidate ("rpc.dictate.Id.error", 1)] long parentId)
                {
                        return this._Service.Gets (parentId);
                }
                /// <summary>
                /// 获取节点树
                /// </summary>
                /// <returns></returns>
                public TreeNode[] GetTrees ()
                {
                        return this._Service.GetTrees ();
                }
                /// <summary>
                /// 设置节点名
                /// </summary>
                /// <param name="param"></param>
                public void Set (LongParam<string> param)
                {
                        this._Service.Set (param.Id, param.Param);
                }
        }
}
